import re

result = {'digit': 0, 'upper': 0, 'lower': 0, 'string': 0}


# 判断密码长度是否超过8位
def len_pwd(user_pwd):
    if len(user_pwd) >= 8:
        return 1
    else:
        return 0


# 包括大、小写字母.数字.其它符号,以上四种至少三种
def str_pwd(user_pwd):
    b = 0
    for i in user_pwd:
        if i.isdigit():
            result['digit'] = 1
        elif i.isupper():
            result['upper'] = 1
        elif i.islower():
            result['lower'] = 1
        else:
            result['string'] = 1
    for i in result:
        if result[i] != 0:
            b = b + 1
    if b >= 3:
        return 1
    else:
        return 0


# 判断是否有长度超过或等于3的子串重复
def re_pwd(user_pwd):
    for i in range(len(user_pwd)):
        if user_pwd.count(user_pwd[i: i + 3]) >= 3:
            return 0
    return 1


user_pwd = input("请输入密码:")
pwd_result = 2
a = len_pwd(user_pwd)
b = str_pwd(user_pwd)
c = re_pwd(user_pwd)
pwd_result = int(a + b + c)
print(f"密码评分等级:{pwd_result}")
if b == 0:
    print("大、小写字母.数字.其它符号,以上四种至少三种")
if a == 0:
    print("长度未超过8位")
if c == 0:
    print("不能有长度超过或等于3的子串重复")
